//
//  MKDownloadTableViewCell.m
//  ManKeCartoon
//
//  Created by 邹功梁 on 15/10/27.
//  Copyright © 2015年 ManKe. All rights reserved.
//

#import "MKDownloadTableViewCell.h"
#import "MKBaseHeader.h"
@implementation MKDownloadTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        _comicImage = [[UIImageView alloc] initWithFrame:CGRectMake(10 * WIDTH, 10 * HEIGHT, 90 * WIDTH, 120 * HEIGHT)];
        
        _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(110 * WIDTH, 20 * HEIGHT, SCREEN_WIDTH - 110 * WIDTH, 20 * HEIGHT)];
        _titleLabel.textAlignment = NSTextAlignmentLeft;
        _titleLabel.textColor = [UIColor grayColor];
        _titleLabel.font = [UIFont systemFontOfSize:18.];
        
        _progressView = [[UIProgressView alloc] initWithFrame:CGRectMake(110 * WIDTH, 60 * HEIGHT, SCREEN_WIDTH - 120 * WIDTH, 10 * HEIGHT)];
        _progressView.progressViewStyle = UIProgressViewStyleDefault;
        
        _downloadNowlabel = [[UILabel alloc] initWithFrame:CGRectMake(110 * WIDTH, 90 * HEIGHT, SCREEN_WIDTH - 110 * WIDTH, 10 * HEIGHT)];
        _downloadNowlabel.textAlignment = NSTextAlignmentLeft;
        _downloadNowlabel.font = [UIFont systemFontOfSize:12.];
        _downloadNowlabel.textColor = [UIColor orangeColor];
        
        _bottomView = [[UIView alloc] initWithFrame:CGRectMake(110 * WIDTH, 140 * HEIGHT - 1, SCREEN_WIDTH - 120 * WIDTH, 1)];
        [_bottomView setBackgroundColor:[UIColor colorWithRed:0.93 green:0.93 blue:0.93 alpha:1]];
        
        [self.contentView addSubview:_comicImage];
        [self.contentView addSubview:_titleLabel];
        [self.contentView addSubview:_progressView];
        [self.contentView addSubview:_downloadNowlabel];
        [self.contentView addSubview:_bottomView];
    }
    return self;
}
- (void)setDownloadData:(DownloadData *)model now:(NSInteger)now all:(NSInteger)all
{
    [_comicImage sd_setImageWithURL:[NSURL URLWithString:model.cover_url]];
    _titleLabel.text = model.title;
    _downloadNowlabel.text = [NSString stringWithFormat:@"正在下载 (%ld/%ld)", now, all];
}
- (void)awakeFromNib { 
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
